package com.silverhaze.diamond.common.event;

import com.silverhaze.commons.db.datasource.ObjectEntity;

/**
 * User: Babanin
 * Date: 31.10.2010
 * Time: 0:18:24
 */
public class UIEventClassChanged extends UIEvent {
    private Class<? extends ObjectEntity> entity;

    public UIEventClassChanged(Class<? extends ObjectEntity> entity) {
        this.entity = entity;
    }

    @Override
    public boolean canMergeWith(UIEvent event) {
        return (event instanceof UIEventEntityChanged || event instanceof UIEventClassChanged) && event.getChangedEntityClass().equals(getChangedEntityClass());
    }

    @Override
    public boolean isMergeable() {
        return true;
    }

    @Override
    public void merge(UIEvent event) {
    }

    @Override
    public Class<? extends ObjectEntity> getChangedEntityClass() {
        return entity;
    }

    @Override
    public String toString() {
        return "UIEventClassChanged{ entity=[" + entity + "], serverEvent=" + serverEvent + " }";
    }
}